
#include<stdio.h>
/*
void decimal_binary(int n);

int main()
{
	int n;//需要转换的十进制数
	printf("Please enter the decimal number to convert:\n");
	scanf("%d",&n);
	decimal_binary(n);
}

void decimal_binary(int n)//函数功能：十进制转换为二进制*
{
	int remainder;
	int i = 1;
	while(n != 0)
	{
		remainder = n%2;
		printf("第%d为%d\n",i,remainder);
		i++;
		n /= 2;
	}
}
*/

/******任意进制转换为十进制
#include<stdio.h>
#include<string.h>

int convert_decimal(char a[],int system);

int main()
{
	char a[100];
	int system;
	printf("请输入要转换的数\n");
	gets(a);//输入n进制数存到数组a中
	printf("多少进制\n");
	scanf("%d",&system);
	convert_decimal(a,system);
}

int convert_decimal(char a[],int system)
{
//	char a[100];
	int i,t1,t3,result;
	strupr(a);//将a中的小写字母转换成大写字母
	t3 = strlen(a);
	result = 0;
	for(i = 0;i<t3;i++)
	{
		if(a[i]-'0'>=system&&a[i]<'A' || a[i]-'A'+10>=system)
		{
			printf("输入的数有误\n");
		//	exit(0);
		}
		if(a[i]>='0'&&a[i]<='9')
		{
			t1 = a[i]-'0';
		}
		else if(system>=11&&(a[i]>='A'&&a[i]<='A'+system)-10)
		{
			t1 = a[i] - 'A'+10;
		}
		result = result*system+t1;
	}
	printf("十进制数形式是%ld\n",result);

}
******/
/***小球问题
int main()
{
	int i = 1;
	float rebound_height,total_length;
	rebound_height=100;
	total_length=0;

	for(i;i<11;i++)
	{
		total_length += rebound_height;
		rebound_height /= 2.0;
		total_length += rebound_height;
	}
 	printf("第十次经过%f米  第十次反弹%f高",total_length,rebound_height);
}
***/
/**
int bin_dec(int x,int n)
{
	if(n == 0)
	{
		return 1;
	}
	return x*bin                                                               _dec(x,n-1);
}

void main()
{
	int i,j,n.m;
	int ip[4] = {0};
	char a[33];
	m = 0;
	n = 8;
	printf("输入二进制数：\n");
	scanf("%s",a);
	for(j = 0;j<4;j++)
	{
		for(i = m;i<n;i++)
		{
			if(a[i]=='1')
				ip[j] += bin_dec(2,7-i);
		}
		i += 8;
		m +=8;
		n+=8;
		if(a[i] == '\0')
		{
			break;
		}
	}
	printf("IP: \n");
	printf("%d.%d.%d.%d\n",ip[0],ip[1],ip[2],ip[3]);
}
***/
/***特殊的完全平方数
int main()
{
	int i,j,gewei,shiwei,baiwei;
	j = 10;
	for(i = 100;i <= 999;i++)
	{
		gewei = i%10;
		shiwei = i/10%10;
		baiwei = i/100;
		if(gewei == shiwei || shiwei == baiwei || gewei == baiwei)
		{
			while(j*j <= i)
			{
				if(j*j == i)
				{
					printf("%5d",i);
				}
				j++;	
			}
		}
		j = 10;
	}

}
***/
/*****
int main()
{
	int i,j,n,m,gao,di;
	
	for(i = 100000;i<1000000;i++)
	{
		di = i%1000;
		gao = (i - di)/1000;
		for(j = 99;j<1000;j++)
		{
			if(j*j == i)
			{
				for(n = 1;n<100;n++)
				{
					if(n*n == gao)
					{
						for(m = 1;m<100;m++)
						{
							if(m*m ==di)
							{
								printf("%6d  ",i);
							}
						}
					}
				}
			}
		}
	}
}
*****/
/****求等差数列
int main()
{
	int a,d,i,j;//分别为等差数列的第一项和公差
	int k=0;
	int b[4][5];
	for(a = 1;a<10;a++)
	{
		for(d = 1;d<10;d++)
		{
			if(4*a+6*d == 26&&a*(a+d)*(a+2*d)*(a+3*d)==880)
			{
				printf("等差数列第一项为%d   公差为%d  \n",a,d);
				printf("\n");
				for(i = 0;i<4;i++)
				{
					for(j=0;j<5;j++)
					{
						b[i][j] = a+k*d;
						k++;
						printf("%5d  ",b[i][j]);
					}
					
					printf("\n");
				}
			}
		}
	}
****/
/****
int main()
{
	int a[1000]={0};
	int b[1000]={0};
	int i,j,k,father,son,tag;
	father = 0;
	son = 0;
	j = 0;
	for(k = 1;k < 10000;k++)
	{
		for(i=1;i<k;i++)
		{
			if(k%i==0)
			{
				a[j++] = i;
			}
		}
		j = 0;
		while(a[j] != 0)
		{
			father += a[j]; 
			j++;
		}
		tag = father;
		j = 0;
		for(i = 1;i<father;i++)
		{
			if(father%i == 0)
			{
				b[j++] = i;
			}
		}
		j = 0;
		while(b[j]!=0)
		{
			son += b[j];
			j++;
		}
		if(k == son)
		{
			printf("%d->%d\n",k,father);
		}
	}
}
***/
